package anli;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;

public class demo01 {
    public static void main(String[] args) {
        ArrayList<String> list1=new ArrayList<>(Arrays.asList("张无忌","葛二蛋","张嘎","黄飞鸿"));
        ArrayList<String> list2=new ArrayList<>(Arrays.asList("令狐冲","岳不群","东方不败","张大人","张家界","张晓"));

        // 1.第一个队伍只要前三个名字为3个字的成员姓名

        Stream<String> stream1 = list1.stream().filter(x -> x.length() == 3).limit(3);
        System.out.println("1===================");
        stream1.forEach(System.out::print);

        //2. 第一个队伍只要姓张的成员姓名

        Stream<String> stream2 = list1.stream().filter(x -> x.startsWith("张"));
        System.out.println("2===================");
        stream2.forEach(System.out::print);

        //3.第二个队伍只要姓张的成员姓名
        Stream<String> stream3 = list2.stream().filter(x -> x.startsWith("张"));
        System.out.println("3===================");
        stream3.forEach(System.out::print);

        //4.第二个队伍筛选后不要前两个人

        Stream<String> stream4 = list2.stream().filter(x -> x.startsWith("张")).skip(2);
        System.out.println("4=================");
        stream4.forEach(System.out::print);
        //5.将两个队伍合并成一个队伍
        Stream<String> stream5 = Stream.concat(list1.stream(), list2.stream());
        System.out.println("5=====================");
        stream5.forEach(System.out::println);
        //6.根据姓名创建 person对象，把Person类型的对象放在流中


    }
}
